﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AviumX.AviumCore.WinAPI.Controls
{
    class Button
    {
        //Button - Toxickill
        public string Text = "Button";
        public AviumX.AviumCore.Screen.ScreenX.SystemColors BorderColor = AviumX.AviumCore.Screen.ScreenX.SystemColors.Black;
        public uint Width = 48;
        public uint Height = 10;
        public Window ParentWindow  = new Window(new AviumCore.Screen.Graphics.Vector(),0,0);
        public AviumX.AviumCore.Screen.Graphics.Vector Position = new AviumX.AviumCore.Screen.Graphics.Vector(0, 0);
        public string OnClickDo = string.Empty;
        public string OnRightClickDo = string.Empty;
        public bool Pressed;

        public void Draw()
        {
            Update();
            AviumX.AviumCore.Screen.Graphics.Drawing.DrawRectangle(Position, Width, Height, BorderColor);
            if (Pressed == false)
            {
                AviumX.AviumCore.Screen.Graphics.Drawing.DrawRectangle((uint)Position.x + 1, (uint)Position.y + 1, Width - 2, Height / 2, AviumX.AviumCore.Screen.ScreenX.SystemColors.Silver);
                AviumX.AviumCore.Screen.Graphics.Drawing.DrawRectangle((uint)Position.x + 1, (uint)Position.y + (Height / 2) + 1, Width - 2, (Height / 2) - 2, AviumX.AviumCore.Screen.ScreenX.SystemColors.Gray);
                AviumX.AviumCore.Screen.Graphics.Fonts.FontHandle.Print(AviumX.AviumCore.Screen.Graphics.Fonts.Font.Fonts.EnvySys, AviumX.AviumCore.Screen.ScreenX.SystemColors.Black, Text, Position.x + 1, Position.y + 1);
            }
            else if (Pressed == true)
            {
                AviumX.AviumCore.Screen.Graphics.Drawing.DrawRectangle((uint)Position.x + 1, (uint)Position.y + 1, Width - 2, Height / 2, AviumX.AviumCore.Screen.ScreenX.SystemColors.Gray);
                AviumX.AviumCore.Screen.Graphics.Drawing.DrawRectangle((uint)Position.x + 1, (uint)Position.y + (Height / 2) + 1, Width - 2, (Height / 2) - 2, AviumX.AviumCore.Screen.ScreenX.SystemColors.DarkGray);
                AviumX.AviumCore.Screen.Graphics.Fonts.FontHandle.Print(AviumX.AviumCore.Screen.Graphics.Fonts.Font.Fonts.EnvySys, AviumX.AviumCore.Screen.ScreenX.SystemColors.White, Text, Position.x + 1, Position.y + 1);
            }
        }
        public void Update()
        {
            CheckClicks();
        }
        private void CheckClicks()
        {
            if (ParentWindow.infront == true)
            {
                if (AviumX.AviumCore.Hardware.Mouse.Cursor.CheckMouseLeftClick(Position.x, Position.y, (int)Width, (int)Height) == true)
                {
                    OnClick();
                    Pressed = true;
                }
                if (AviumX.AviumCore.Hardware.Mouse.Cursor.CheckMouseRightClick(Position.x, Position.y, (int)Width, (int)Height) == true)
                {
                    OnRightClick();
                    Pressed = true;
                }
                else
                {
                    Pressed = false;
                }
            }
        }
        private void OnClick()
        {

        }
        private void OnRightClick()
        {

        }
    }
}
